package com.hd.appcommon.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hd.appcommon.entity.DdoaBpm;
import com.hd.appcommon.entity.vo.SubstituteDetailVo;
import com.hd.appcommon.entity.vo.SubstituteExcelVo;
import com.hd.appcommon.entity.vo.SubstituteVo;
import com.hd.appcommon.entity.vo.SubstituteWebVo;
import com.hd.hdxgddcommon.page.MyPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * (DdoaBpm)表数据库访问层
 *
 * @author makejava
 * @since 2023-07-06 14:49:15
 */
@Mapper
public interface DdoaBpmMapper extends BaseMapper<DdoaBpm> {
    @Select("SELECT " +
            "ddoa_bpm.id AS bpmId, " +
            "ddoa_course_replace.evidences AS file_ids," +
            "ddoa_bpm.process_instance_id AS process_id," +
            "ddoa_bpm.job_number, " +
            "ddoa_course_replace.id, " +
            "ddoa_course_replace_course.cour_name," +
            "ddoa_course_replace_course.cour_code," +
            "ddoa_course_replace.major," +
            "ddoa_bpm.name," +
            "ddoa_course_replace.colleges, " +
            "ddoa_course_replace_course.cour_credit," +
            "ddoa_course_replace.application_type," +
            "ddoa_bpm.status ," +
            "ddoa_course_replace.second_status " +
            "From ddoa_bpm " +
            "left join ddoa_course_replace on " +
            "ddoa_bpm.process_instance_id=ddoa_course_replace.process_instance_id " +
            "left join ddoa_course_replace_course on " +
            "ddoa_course_replace_course.process_instance_id= ddoa_bpm.process_instance_id " +
            "${ew.customSqlSegment} GROUP BY ddoa_bpm.id")
    IPage<SubstituteWebVo> getSubstituteVoList(MyPage page, @Param("ew") QueryWrapper<SubstituteWebVo> queryWrapper);
    @Select("SELECT " +
            "ddoa_course_replace.id, " +
            "ddoa_course_replace_course.cour_name," +
            "ddoa_course_replace_course.cour_code," +
            "ddoa_course_replace.major," +
            "ddoa_bpm.name," +
            "ddoa_course_replace.colleges, " +
            "ddoa_course_replace_course.cour_credit," +
            "ddoa_course_replace.application_type," +
            "ddoa_bpm.status ," +
            "ddoa_course_replace.second_status " +
            "From ddoa_bpm " +
            "left join ddoa_course_replace on " +
            "ddoa_bpm.process_instance_id=ddoa_course_replace.process_instance_id " +
            "left join ddoa_course_replace_course on " +
            "ddoa_course_replace_course.process_instance_id= ddoa_bpm.process_instance_id " +
            "${ew.customSqlSegment} GROUP BY ddoa_bpm.id")
    List<SubstituteExcelVo> getSubstituteVoList2(@Param("ew") QueryWrapper<SubstituteWebVo> queryWrapper);
    @Select("SELECT  ddoa_course_replace_course.cour_code, " +
            "ddoa_course_replace_course.cour_name, " +
            "ddoa_course_replace_course.cour_type, " +
            "ddoa_course_replace_course.cour_credit, " +
            "course.cour_code_specific as term " +
            "FROM ddoa_bpm " +
            "LEFT JOIN ddoa_course_replace_course " +
            "ON ddoa_bpm.process_instance_id = ddoa_course_replace_course.process_instance_id " +
            "LEFT JOIN course " +
            "ON ddoa_course_replace_course.cour_code = course.cour_code" +
            " ${ew.customSqlSegment} ")
    SubstituteDetailVo getDetail(@Param("ew") QueryWrapper<SubstituteDetailVo> queryWrapper);
}
